/*
 ============================================================================
 Name		: playAppUi.cpp
 Author	  : CODIO
 Copyright   : CODIO
 Description : CplayAppUi implementation
 ============================================================================
 */

// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <hlplch.h>


#include <play_0xEA73EC6F.rsg>

#include "play_0xEA73EC6F.hlp.hrh"
#include "play.hrh"
#include "play.pan"
#include "playApplication.h"
#include "playAppUi.h"
#include "playAppView.h"

_LIT( KFileName, "C:\\private\\EA73EC6F\\play.txt" );
_LIT( KText, "CODIO");



// ============================ MEMBER FUNCTIONS ===============================


// -----------------------------------------------------------------------------
// CplayAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CplayAppUi::ConstructL()
	{
	// Initialise app UI with standard value.
	BaseConstructL(CAknAppUi::EAknEnableSkin);

	// Create view object
	iAppView = CplayAppView::NewL(ClientRect());
	//HBufC8* data2 = HBufC8::NewL(204800);
		
	
	}
// -----------------------------------------------------------------------------
// CplayAppUi::CplayAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CplayAppUi::CplayAppUi()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CplayAppUi::~CplayAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CplayAppUi::~CplayAppUi()
	{
	if (iAppView)
		{
		delete iAppView;
		iAppView = NULL;
		}
	/*if (data2 != NULL)
		   {
		    delete data2;
			data2 = NULL;	
		   }	
	*/
			

	}

// -----------------------------------------------------------------------------
// CplayAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CplayAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case EEikCmdExit:
		case EAknSoftkeyExit:
			Exit();
			break;

		case ECommand1:
			{
			
			
			/*RFile file;
			RFs fs;	
			_LIT(KFileName2, "c:\\Data\\1.3gp");
			
			User::LeaveIfError(fs.Connect());				
			User::LeaveIfError(file.Open(fs, KFileName2, EFileRead));

			
			TInt length2;
			file.Size(length2);
			
			HBufC8 * data2=HBufC8::NewLC(length2);

			TPtr8 ptr2 = data2->Des();   
			file.Read(ptr2);	
			file.Close();
			fs.Close();
			CleanupStack::Pop(data2);
			*/
			
			_LIT(KFileName1,"c:\\Data\\1.mp4");
			iAppView->iVideoPlayer->OpenFileL(KFileName1);
			
			//iAppView->iVideoPlayer->OpenDesL(*data2);
			
			
			/*while(1)
				{
				if (EPlayerPlayComplete == iAppView->iVideoPlayer->iState)
					{
					iAppView->iVideoPlayer->OpenDesL(*data2);
					break;
					}				
				}
			*/
            
			
			//_LIT(KFileName1, "c:\\Data\\1.3gp");
			//iAppView->iVideoPlayer->OpenFileL(KFileName1);
			//_LIT(KUrlFile,"rtsp://127.0.0.1/1.3gp");
			//iAppView->iVideoPlayer->OpenUrlL(KUrlFile);
			
			}
			break;
		case ECommand2:
			{
			iAppView->iVideoPlayer->PauseL();
			}
			break;
		case EHelp:
			{
			}
			break;
		case EAbout:
			{

			CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog();
			dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
			HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
			dlg->QueryHeading()->SetTextL(*title);
			CleanupStack::PopAndDestroy(); //title
			HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
			dlg->SetMessageTextL(*msg);
			CleanupStack::PopAndDestroy(); //msg
			dlg->RunLD();
			}
			break;
		default:
			Panic(EplayUi);
			break;
		}
	}
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CplayAppUi::HandleStatusPaneSizeChange()
	{
	iAppView->SetRect(ClientRect());
	}

CArrayFix<TCoeHelpContext>* CplayAppUi::HelpContextL() const
	{
#warning "Please see comment about help and UID3..."
	// Note: Help will not work if the application uid3 is not in the
	// protected range.  The default uid3 range for projects created
	// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they
	// can be self signed and installed on the device during testing.
	// Once you get your official uid3 from Symbian Ltd. and find/replace
	// all occurrences of uid3 in your project, the context help will
	// work. Alternatively, a patch now exists for the versions of 
	// HTML help compiler in SDKs and can be found here along with an FAQ:
	// http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument
	CArrayFixFlat<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat<
			TCoeHelpContext> (1);
	CleanupStack::PushL(array);
	array->AppendL(TCoeHelpContext(KUidplayApp, KGeneral_Information));
	CleanupStack::Pop(array);
	return array;
	}

// End of File
